package main.java.com.lee.thread;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.locks.Lock;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2021/12/4
 */
public class EleCal {


	public static void main(String[] args) {
		//南
		BigDecimal southPrevious = BigDecimal.valueOf(20736.7);
		BigDecimal southCurrent = BigDecimal.valueOf(20982.5);

		//北
		BigDecimal northPrevious = BigDecimal.valueOf(15852.8);
		BigDecimal northCurrent = BigDecimal.valueOf(16012.4);

		BigDecimal money = BigDecimal.valueOf(193.99);
		BigDecimal total = northCurrent.subtract(northPrevious).add(southCurrent.subtract(southPrevious));

		int month=6;
		cal(month, southPrevious, southCurrent, money, total, "朝向南");
		cal(month, northPrevious, northCurrent, money, total, "朝向北");

	}

	// 朝南租客旧租客, 2吨水费未付款, 需房东结清. 有聊天记录
	private static void cal(int month, BigDecimal one, BigDecimal three, BigDecimal amount, BigDecimal total, String dir) {
		System.out.println(dir + "," + month + "月初抄表: " + one + " ," + month + "月底抄表: " + three + ", 本期电量: " + three.subtract(one) + ", 本期电费: " + amount.multiply(three.subtract(one)).setScale(10, RoundingMode.HALF_UP).divide(total, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
	}

	//上一期抄表: 355.6 ,当期抄表: 366.2, 电量: 10.6, 电费: 27.0848275862
}
